Qt 6.8 requires macSO 12 or higher: no need to compile against older
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Fri, 4 Apr 2025 09:05:41 +0000 (11:05 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Mon, 7 Apr 2025 10:53:37 +0000 (10:53 +0000)
clean up preprocessor directives for older macOS releases that are not
supported by macOS minimum required release from the Qt 6.8 release we
require

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/gui/folder.cpp
src/libsync/discovery.cpp
src/libsync/filesystem.cpp
src/libsync/filesystem.h
src/libsync/owncloudpropagator.cpp
src/libsync/propagatedownload.cpp
src/libsync/propagatedownload.h
src/libsync/propagatorjobs.cpp
test/syncenginetestutils.cpp
test/testpermissions.cpp

index cc5a0f74a76912deeb4e3dd87ac2fbac5bf59747..f89dab9c58289338d3fb8ce81358a0dda3ab931f 100644 (file)
@@ -1736,11 +1736,9 @@ void Folder::slotNeedToRemoveRemnantsReadOnlyFolders(const QList<SyncFileItemPtr
 
     setSyncPaused(true);
     for(const auto &oneFolder : folders) {
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
         const auto fileInfo = QFileInfo{localPath + oneFolder->_file};
         const auto parentFolderPath = fileInfo.dir().absolutePath();
         const auto parentPermissionsHandler = FileSystem::FilePermissionsRestore{parentFolderPath, FileSystem::FolderPermissions::ReadWrite};
-#endif
         if (oneFolder->_type == ItemType::ItemTypeDirectory) {
             FileSystem::removeRecursively(localPath + oneFolder->_file);
         } else {
index ce8ef8d306e0f3d81ff0634c9d5fb549c28b541d..9d7cede827ba021d45f1f26b2186c10006a14536 100644 (file)
@@ -1870,11 +1870,9 @@ bool ProcessDirectoryJob::checkPermissions(const OCC::SyncFileItemPtr &item)
             item->_instruction = CSYNC_INSTRUCTION_ERROR;
             item->_errorString = tr("Not allowed because you don't have permission to add subfolders to that folder");
             const auto localPath = QString{_discoveryData->_localDir + item->_file};
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
             qCWarning(lcDisco) << "unexpected new folder in a read-only folder will be made read-write" << localPath;
             FileSystem::setFolderPermissions(localPath, FileSystem::FolderPermissions::ReadWrite);
             emit _discoveryData->remnantReadOnlyFolderDiscovered(item);
-#endif
             return false;
         } else if (!item->isDirectory() && !perms.hasPermission(RemotePermissions::CanAddFile)) {
             qCWarning(lcDisco) << "checkForPermission: ERROR" << item->_file;
@@ -2078,11 +2076,9 @@ int ProcessDirectoryJob::processSubJobs(int nbJobs)
                     _dirItem->_instruction = CSYNC_INSTRUCTION_ERROR;
                     _dirItem->_errorString = tr("Not allowed because you don't have permission to add subfolders to that folder");
                     const auto localPath = QString{_discoveryData->_localDir + _dirItem->_file};
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
                     qCWarning(lcDisco) << "unexpected new folder in a read-only folder will be made read-write" << localPath;
                     FileSystem::setFolderPermissions(localPath, FileSystem::FolderPermissions::ReadWrite);
                     emit _discoveryData->remnantReadOnlyFolderDiscovered(_dirItem);
-#endif
                 }
 
                 _dirItem->_direction = _dirItem->_direction == SyncFileItem::Up ? SyncFileItem::Down : SyncFileItem::Up;
index 8361d8af550ee655a89b216e78231de5673496ef..580562acc3d4913e804442ba796d945a2ae69a97 100644 (file)
@@ -274,11 +274,9 @@ bool FileSystem::removeRecursively(const QString &path, const std::function<void
         } else {
             QString removeError;
 
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
             const auto fileInfo = QFileInfo{di.filePath()};
             const auto parentFolderPath = fileInfo.dir().absolutePath();
             const auto parentPermissionsHandler = FileSystem::FilePermissionsRestore{parentFolderPath, FileSystem::FolderPermissions::ReadWrite};
-#endif
             removeOk = FileSystem::remove(di.filePath(), &removeError);
             if (removeOk) {
                 if (onDeleted)
@@ -295,12 +293,10 @@ bool FileSystem::removeRecursively(const QString &path, const std::function<void
             allRemoved = false;
     }
     if (allRemoved) {
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
         const auto fileInfo = QFileInfo{path};
         const auto parentFolderPath = fileInfo.dir().absolutePath();
         const auto parentPermissionsHandler = FileSystem::FilePermissionsRestore{parentFolderPath, FileSystem::FolderPermissions::ReadWrite};
         FileSystem::setFolderPermissions(path, FileSystem::FolderPermissions::ReadWrite);
-#endif
         allRemoved = QDir().rmdir(path);
         if (allRemoved) {
             if (onDeleted)
@@ -326,7 +322,6 @@ bool FileSystem::getInode(const QString &filename, quint64 *inode)
     return false;
 }
 
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
 bool FileSystem::setFolderPermissions(const QString &path,
                                       FileSystem::FolderPermissions permissions) noexcept
 {
@@ -564,6 +559,4 @@ FileSystem::FilePermissionsRestore::~FilePermissionsRestore()
     }
 }
 
-#endif
-
 } // namespace OCC
index e14cf27681db0cbd3da22e6b09c92c37b5528d16..e0439b8f52be4955f33013dd9b9e77b19edc2649 100644 (file)
@@ -128,9 +128,7 @@ namespace FileSystem {
     bool OWNCLOUDSYNC_EXPORT setFolderPermissions(const QString &path,
                                                   FileSystem::FolderPermissions permissions) noexcept;
 
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
     bool OWNCLOUDSYNC_EXPORT isFolderReadOnly(const std::filesystem::path &path) noexcept;
-#endif
 }
 
 /** @} */
index e239f05afbf042b22228b6aabaf00e62a682bd51..beec5b96610a665d64eb1da00b560375d05bc47e 100644 (file)
@@ -1465,7 +1465,6 @@ void PropagateDirectory::slotSubJobsFinished(SyncFileItem::Status status)
             || _item->_instruction == CSYNC_INSTRUCTION_NEW
             || _item->_instruction == CSYNC_INSTRUCTION_UPDATE_METADATA) {
 
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
             if (!_item->_remotePerm.isNull() &&
                 !_item->_remotePerm.hasPermission(RemotePermissions::CanAddFile) &&
                 !_item->_remotePerm.hasPermission(RemotePermissions::CanAddSubDirectories)) {
@@ -1530,7 +1529,6 @@ void PropagateDirectory::slotSubJobsFinished(SyncFileItem::Status status)
                     _item->_errorString = tr("The folder %1 cannot be made read-only: %2").arg("", tr("unknown exception"));
                 }
             }
-#endif
             if (!_item->_isAnyCaseClashChild && !_item->_isAnyInvalidCharChild) {
                 if (_item->isEncrypted()) {
                     _item->_e2eCertificateFingerprint = propagator()->account()->encryptionCertificateFingerprint();
index 9c6f1b579fe1a811a6517d4bb60194b2a338d812..2b05b51f97be3058d8232138f994d448a6785d2b 100644 (file)
@@ -769,19 +769,16 @@ void PropagateDownloadFile::setDeleteExistingFolder(bool enabled)
 
 void PropagateDownloadFile::done(const SyncFileItem::Status status, const QString &errorString, const ErrorCategory category)
 {
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
     if (_needParentFolderRestorePermissions) {
         FileSystem::setFolderPermissions(QString::fromStdWString(_parentPath.wstring()), FileSystem::FolderPermissions::ReadOnly);
         emit propagator()->touchedFile(QString::fromStdWString(_parentPath.wstring()));
         _needParentFolderRestorePermissions = false;
     }
-#endif
     PropagateItemJob::done(status, errorString, category);
 }
 
 void PropagateDownloadFile::makeParentFolderModifiable(const QString &fileName)
 {
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
     try {
         const auto newDirPath = std::filesystem::path{fileName.toStdWString()};
         Q_ASSERT(newDirPath.has_parent_path());
@@ -805,7 +802,6 @@ void PropagateDownloadFile::makeParentFolderModifiable(const QString &fileName)
         emit propagator()->touchedFile(QString::fromStdWString(_parentPath.wstring()));
         _needParentFolderRestorePermissions = true;
     }
-#endif
 }
 
 const char owncloudCustomSoftErrorStringC[] = "owncloud-custom-soft-error-string";
@@ -1349,13 +1345,11 @@ void PropagateDownloadFile::downloadFinished()
         return;
     }
 
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
     if (_needParentFolderRestorePermissions) {
         FileSystem::setFolderPermissions(QString::fromStdWString(_parentPath.wstring()), FileSystem::FolderPermissions::ReadOnly);
         emit propagator()->touchedFile(QString::fromStdWString(_parentPath.wstring()));
         _needParentFolderRestorePermissions = false;
     }
-#endif
 
     FileSystem::setFileHidden(filename, false);
 
index 912cab03e9839430ae881135431169e3c0bc9b85..2200ee531b34e063edee45411bd03f3c094e1da4 100644 (file)
@@ -23,9 +23,7 @@
 #include <QBuffer>
 #include <QFile>
 
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
 #include <filesystem>
-#endif
 
 namespace OCC {
 class PropagateDownloadEncrypted;
@@ -270,9 +268,7 @@ private:
 
     PropagateDownloadEncrypted *_downloadEncryptedHelper = nullptr;
 
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
     std::filesystem::path _parentPath;
-#endif
     bool _needParentFolderRestorePermissions = false;
 };
 }
index 0759e6bd8ecafaa03c63764a5e154aa3c18a6f97..b1d85e198989d1af624b67f10332ba0239a72420 100644 (file)
@@ -32,9 +32,7 @@
 #include <qstack.h>
 #include <QCoreApplication>
 
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
 #include <filesystem>
-#endif
 #include <ctime>
 
 
@@ -62,12 +60,10 @@ bool PropagateLocalRemove::removeRecursively(const QString &path)
     QString absolute = propagator()->fullLocalPath(_item->_file + path);
     QStringList errors;
     QList<QPair<QString, bool>> deleted;
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
     const auto fileInfo = QFileInfo{absolute};
     const auto parentFolderPath = fileInfo.dir().absolutePath();
     const auto parentPermissionsHandler = FileSystem::FilePermissionsRestore{parentFolderPath, FileSystem::FolderPermissions::ReadWrite};
     FileSystem::setFolderPermissions(absolute, FileSystem::FolderPermissions::ReadWrite);
-#endif
     bool success = FileSystem::removeRecursively(
         absolute,
         [&deleted](const QString &path, bool isDir) {
@@ -132,12 +128,10 @@ void PropagateLocalRemove::start()
             }
         } else {
             if (FileSystem::fileExists(filename)) {
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
                 const auto fileInfo = QFileInfo{filename};
                 const auto parentFolderPath = fileInfo.dir().absolutePath();
 
                 const auto parentPermissionsHandler = FileSystem::FilePermissionsRestore{parentFolderPath, FileSystem::FolderPermissions::ReadWrite};
-#endif
 
                 if (!FileSystem::remove(filename, &removeError)) {
                     done(SyncFileItem::NormalError, removeError, ErrorCategory::GenericError);
@@ -200,7 +194,6 @@ void PropagateLocalMkdir::startLocalMkdir()
         return;
     }
 
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
     auto parentFolderPath = std::filesystem::path{};
     auto parentNeedRollbackPermissions = false;
     try {
@@ -225,7 +218,6 @@ void PropagateLocalMkdir::startLocalMkdir()
     {
         qCWarning(lcPropagateLocalMkdir) << "exception when checking parent folder access rights";
     }
-#endif
 
     emit propagator()->touchedFile(newDirStr);
     QDir localDir(propagator()->localPath());
@@ -234,7 +226,6 @@ void PropagateLocalMkdir::startLocalMkdir()
         return;
     }
 
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
     if (!_item->_remotePerm.isNull() &&
         !_item->_remotePerm.hasPermission(RemotePermissions::CanAddFile) &&
         !_item->_remotePerm.hasPermission(RemotePermissions::CanAddSubDirectories)) {
@@ -279,7 +270,6 @@ void PropagateLocalMkdir::startLocalMkdir()
     {
         qCWarning(lcPropagateLocalMkdir) << "exception when checking parent folder access rights";
     }
-#endif
 
     // Insert the directory into the database. The correct etag will be set later,
     // once all contents have been propagated, because should_update_metadata is true.
@@ -360,7 +350,6 @@ void PropagateLocalRename::start()
             return;
         }
 
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
         auto targetParentFolderPath = std::filesystem::path{};
         auto targetParentFolderWasReadOnly = false;
         try {
@@ -431,31 +420,26 @@ void PropagateLocalRename::start()
         };
 
         const auto folderPermissionsHandler = FileSystem::FilePermissionsRestore{existingFile, FileSystem::FolderPermissions::ReadWrite};
-#endif
 
         emit propagator()->touchedFile(existingFile);
         emit propagator()->touchedFile(targetFile);
         if (QString renameError; !FileSystem::rename(existingFile, targetFile, &renameError)) {
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
             if (targetParentFolderWasReadOnly) {
                 restoreTargetPermissions(targetParentFolderPath);
             }
             if (originParentFolderWasReadOnly) {
                 restoreTargetPermissions(originParentFolderPath);
             }
-#endif
             done(SyncFileItem::NormalError, renameError, ErrorCategory::GenericError);
             return;
         }
 
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
         if (targetParentFolderWasReadOnly) {
             restoreTargetPermissions(targetParentFolderPath);
         }
         if (originParentFolderWasReadOnly) {
             restoreTargetPermissions(originParentFolderPath);
         }
-#endif
     }
 
     SyncJournalFileRecord oldRecord;
index 637c9099c415ce43ad8a9e8d5f5f31e6949bdca3..8eac8a06ecba1a68049e37758db106b2372c68fa 100644 (file)
@@ -17,9 +17,7 @@
 #include <QJsonValue>
 
 #include <memory>
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
 #include <filesystem>
-#endif
 
 PathComponents::PathComponents(const char *path)
     : PathComponents { QString::fromUtf8(path) }
@@ -52,11 +50,9 @@ void DiskFileModifier::remove(const QString &relativePath)
     if (fi.isFile()) {
         QVERIFY(_rootDir.remove(relativePath));
     } else {
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
         const auto pathToDelete = fi.filePath().toStdWString();
         std::filesystem::permissions(pathToDelete, std::filesystem::perms::owner_exec, std::filesystem::perm_options::add);
         QVERIFY(std::filesystem::remove_all(pathToDelete));
-#endif
     }
 }
 
index a090d3b6fe14139374e4fa096d97fa681e818e25..5a1345741ee7fe4bdb36fad4a0e0f5ca83c35fb8 100644 (file)
@@ -11,9 +11,7 @@
 
 #include <QtTest>
 
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
 #include <filesystem>
-#endif
 #include <iostream>
 
 using namespace OCC;
@@ -91,7 +89,6 @@ private slots:
         QStandardPaths::setTestModeEnabled(true);
     }
 
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
     void t7pl()
     {
         FakeFolder fakeFolder{ FileInfo() };
@@ -428,7 +425,6 @@ private slots:
         QCOMPARE(count, 2);
         QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
     }
-#endif
 
     static void setAllPerm(FileInfo *fi, OCC::RemotePermissions perm)
     {
@@ -604,7 +600,6 @@ private slots:
         QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
     }
 
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
     static void demo_perms(std::filesystem::perms p)
     {
         using std::filesystem::perms;
@@ -952,7 +947,6 @@ private slots:
         QVERIFY(ensureReadOnlyItem("/readOnlyFolder/test/newFile.txt"));
         QVERIFY(ensureReadOnlyItem("/readOnlyFolder/newFolder"));
     }
-#endif
 };
 
 QTEST_GUILESS_MAIN(TestPermissions)